<template>
    <div class="teacher-container" v-loading="loading" :class="{ 'is-mobile': $isMobile }">
        <div v-for="item in datas" :key="item.id" class="teacher-item" v-if="item.teachers && item.teachers.length">
            <div class="item-title">{{ item.title }}</div>

            <div class="item-infos">
                <div class="item-detail" v-for="(teacher, index) in item.teachers" :key="index">
                    <div class="avatar">
                        <img :src="teacher.avatar">
                    </div>
                    <div class="name">
                        {{ teacher.name }}
                    </div>

                    <div class="shenfen"> {{ teacher.title }}</div>

                </div>
            </div>
        </div>

    </div>
</template>

<script>
export default {
    name: "teacherList",
    data() {
        return {
            datas: [],
            loading: false
        }
    },
    mounted() {
        this.getData();
    },
    methods: {

        async getData() {
            const loading = this.$loading();
            const { data } = await this.$fetch.get(`/api/topic/teacherList`);
            this.datas = data;
            loading.close();
        }

    }
}
</script>

<style lang="less" scoped>
.teacher-container {
    padding-left: 60px;
    width: 100%;
    box-sizing: border-box;
    height: 100%;


    .teacher-item {
        padding-top: 25px;
        display: flex;
        flex-direction: column;
        font-size: 16px;

        .item-title {
            height: 34px;
            min-width: 166px;
            max-width: max-content;
            background: url(~@/assets/topic-title-bg.png) center center no-repeat;
            background-size: cover;
            font-family: PingFangSC, PingFang SC;
            font-weight: 600;
            font-size: 16px;
            text-indent: 14px;
            color: #FFFFFF;
            line-height: 34px;
            text-align: left;
            font-style: normal;
            cursor: default;
        }

        .item-infos {
            display: flex;
            flex-direction: row;
            flex-wrap: wrap;
            width: 100%;
            margin-top: 16px;

            .item-detail {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                width: 210px;
                background: #F8F9FB;
                border-radius: 8px;
                margin-right: 10px;
                margin-bottom: 20px;

                >:nth-child(4n) {
                    margin-right: 0;
                }

                .avatar {
                    width: 110px;
                    height: 110px;
                    margin-top: 10px;

                    img {
                        width: 100%;
                        height: 100%;
                        border-radius: 50%;

                    }
                }

                .name {
                    margin-top: 10px;
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 600;
                    font-size: 16px;
                    color: #333333;
                    line-height: 22px;
                    text-align: center;
                    font-style: normal;
                }

                .shenfen {
                    margin-top: 8px;
                    font-family: PingFangSC, PingFang SC;
                    font-weight: 400;
                    font-size: 12px;
                    color: #484848;
                    line-height: 17px;
                    text-align: center;
                    font-style: normal;
                    margin-bottom: 25px;
                }

            }
        }
    }


}

.teacher-container.is-mobile { 
    padding-left: 10px;

    .teacher-item {
        padding-top: 10px;

        .item-detail {
            width: calc(50% - 10px);
            margin-right: 5px;
            margin-left: 5px;
        }
    }

    .item-infos {
        margin-top: 10px;
    }
}
</style>